package com.yaorange.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yaorange.entity.AssociationCouncil;
import com.yaorange.mapper.AssociationCouncilMapper;
import com.yaorange.response.PageResult;
import com.yaorange.service.AssociationCouncilService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 江就
 * @Version 1.0
 * @Date 2025/6/25
 * @Description 协会理事会成员信息Service实现类
 */
@Service
public class AssociationCouncilServiceImpl implements AssociationCouncilService {

    @Resource private AssociationCouncilMapper associationCouncilMapper;

    /**
     * 插入协会理事会成员信息
     */
    @Override
    public int insert(AssociationCouncil council) {
        return associationCouncilMapper.insert(council);
    }

    /**
     * 根据主键更新协会理事会成员信息
     */
    @Override
    public int updateById(AssociationCouncil council) {
        return associationCouncilMapper.updateById(council);
    }

    /**
     * 根据主键删除协会理事会成员信息
     */
    @Override
    public int deleteById(Long id) {
        return associationCouncilMapper.deleteById(id);
    }

    /**
     * 根据主键查询协会理事会成员信息
     */
    @Override
    public AssociationCouncil selectById(Long id) {
        return associationCouncilMapper.selectById(id);
    }

    /**
     * 查询所有协会理事会成员信息
     */
    @Override
    public List<AssociationCouncil> selectAll(AssociationCouncil query) {
        return associationCouncilMapper.selectAll(query);
    }

    /**
     * 分页查询协会理事会成员信息
     */
    @Override
    public PageResult<AssociationCouncil> selectPage(AssociationCouncil query, Integer page, Integer size) {
        PageHelper.startPage(page, size);
        List<AssociationCouncil> list = associationCouncilMapper.selectAll(query);
        PageInfo pageInfo = new PageInfo<>(list);
        return PageResult.builder()
                         .total(pageInfo.getTotal())
                         .data(pageInfo.getList())
                         .build();
    }
}
